<?php
/*
 * @Author: lokei
 * @Date: 2023-04-23 19:15:03
 * @LastEditors: lokei
 * @LastEditTime: 2023-04-23 19:22:43
 * @Description: 
 */
namespace App\Http\Controllers\Store;

use App\Common\Tools\ResultTool;
use App\Http\Controllers\Controller;
use App\Models\Store\ConfModel;
use Illuminate\Http\Request;

class RecommendController extends Controller {
    public function get() {
        $store_conf = ConfModel::first();
        if(is_null($store_conf)) {
            $store_conf = new ConfModel();
            $store_conf->recommend_stores = '';
            $store_conf->save();
        }
        $res = ResultTool::success();
        $res['data']['stores'] = $store_conf->recommend_stores;
        return $res;
    }

    public function set(Request $request) {
        $store_conf = ConfModel::first();
        if(is_null($store_conf)) {
            $store_conf = new ConfModel();
        }
        $store_conf->recommend_stores = $request->input('stores');
        $store_conf->save();
        return ResultTool::success();
    }
}